//--------------------Sonic CD HUD Script---------------------//
//--------Scripted by Christian Whitehead 'The Taxman'--------//
//-------Unpacked By Rubberduckycooly's Script Unpacker-------//

// Aliases
// Not all of these are used here in the HUD script, some are just used as a way for other objects to globally transmit values
private alias Object.Value0 : Object.Timer     //	you know this one
private alias Object[6].Value1 : Object.CameraState     // which cam ur watching
private alias Object.Value2 : Object.Static     // for when an animatronic moves while you watch them

private alias Object.Value3 : Object.FlashOn

private alias object.value9 : Camera.Scroll
private alias object.value10 : Camera.ScrollDirection

private alias object.value11 : Camera.ScrollTimer

private alias object.value12 : Bonnie.Pose
private alias object.value13 : Chica.Pose

private alias Object[14].Value12 : Object.EndoActivate

private alias Object[28].Value12 : Object.ShadowFreddyActivate 

private alias Object[16].Value3 : Object.PuppetWind 


// Game Mode Aliases
public value OfficePower = 100;
public value CameraEnabled = 0;

// Priority
private alias 1 : PRIORITY_ACTIVE

private alias 0  : CAMERA_WAITACTIVATE
private alias 1  : CAMERA_FLIPUP
private alias 2  : CAMERA_MAIN
private alias 10  : CAMERA_EXIT

private alias 0 : CAM_SHOWSTAGE_0
private alias 1 : CAM_DININGHALL_1
private alias 2 : CAM_BACKSTAGE_2
private alias 3 : CAM_PIRATESCOVE_3
private alias 4 : CAM_WESTHALL_4
private alias 5 : CAM_CLOSET_5
private alias 6 : CAM_WHALLCORNER_6
private alias 7 : CAM_EASTHALL_7
private alias 8 : CAM_EHALLCORNER_8
private alias 9 : CAM_KITCHEN_9
private alias 10 : CAM_BATHROOMS_10
private alias 11 : CAM_PRIZECORNER_11

//MASK

private alias object[10].state : Freddy.State
private alias object[11].state : Bonnie.State
private alias object[12].state : Chica.State
private alias object[13].state : Foxy.State
private alias Object[13].Value5 : Object.CurtainState

private alias object[14].state : Endo.State
private alias object[16].state : Puppet.State


private alias object[18].state : WitheredFreddy.State
private alias object[19].state : WitheredBonnie.State
private alias object[20].state : WitheredChica.State
private alias object[21].state : WitheredFoxy.State

private alias object[28].state : ShadowFreddy.State

event ObjectMain




end event

event ObjectDraw

	if object[6].state == 2
		DrawRect(0, 0, screen.xsize, screen.ysize, 0, 0, 0, 255)// 1
	//	CallFunction(Camera_TextDrawing)


		temp5 = 45
		temp5 += object.CameraState


		Camera.ScrollTimer++
		if Camera.ScrollTimer >= 6
			if Camera.ScrollDirection == 0
				temp6 = screen.xcenter
				temp6 /= 2
				temp6 += 100
				if camera.scroll > temp6
					Camera.Scroll -= 1
				else
					Camera.ScrollDirection = 1	
				end if
			else
				temp6 = screen.xcenter
				temp6 *= 2
				temp6 -= 200
				if camera.scroll < temp6
					Camera.Scroll += 1
				else
					Camera.ScrollDirection = 0	
				end if
			end if	
			Camera.ScrollTimer = 0
		end if


		//swhostage
		switch Object.CameraState 
			case CAM_KITCHEN_9

			break
			case CAM_PRIZECORNER_11
				DrawSpriteScreenXY(86, Camera.Scroll, 170)	//
			break
			default
				DrawSpriteScreenXY(temp5, Camera.Scroll, 190)	//
			break
		end switch

		
			switch Puppet.State
				case CAM_PRIZECORNER_11
					if Object.CameraState == Puppet.State
						if Object[16].PuppetWind > 0
							DrawSpriteScreenXY(87, Camera.Scroll, 65)	//stage
						else
							DrawSpriteScreenXY(88, Camera.Scroll, -25)	//stage
						end if
					end if
				break
				case 15
					if Object.CameraState == CAM_PRIZECORNER_11
						DrawSpriteScreenXY(88, Camera.Scroll, -25)	//stage
					end if	
				break
			end switch
		



		if Object.CameraState == Chica.State
			switch Chica.State
			case CAM_SHOWSTAGE_0
				DrawSpriteScreenXY(68, Camera.Scroll, 100)	//stage
			break
			case CAM_DININGHALL_1
				DrawSpriteScreenXY(69, Camera.Scroll, 100)	//stage
			break	
			case CAM_BATHROOMS_10
				if object[6].value13 == 0
					DrawSpriteScreenXY(70, Camera.Scroll, 100)	//stage
				else
					DrawSpriteScreenXY(71, Camera.Scroll, 155)	//stage
				end if
			break	
			case CAM_EASTHALL_7
				DrawSpriteScreenXY(72, Camera.Scroll, 135)	//dining room
			break
			case CAM_EHALLCORNER_8
				DrawSpriteScreenXY(73, Camera.Scroll, 70)	//dining room
			break
			end switch
		end if


		if Object.CameraState == Chica.State
			switch Chica.State
			case CAM_SHOWSTAGE_0
				DrawSpriteScreenXY(68, Camera.Scroll, 100)	//stage
			break
			case CAM_DININGHALL_1
				DrawSpriteScreenXY(69, Camera.Scroll, 100)	//stage
			break	
			case CAM_BATHROOMS_10
				if object[6].value13 == 0
					DrawSpriteScreenXY(70, Camera.Scroll, 100)	//stage
				else
					DrawSpriteScreenXY(71, Camera.Scroll, 155)	//stage
				end if
			break	
			case CAM_EASTHALL_7
				DrawSpriteScreenXY(72, Camera.Scroll, 135)	//dining room
			break
			case CAM_EHALLCORNER_8
				DrawSpriteScreenXY(73, Camera.Scroll, 70)	//dining room
			break
			end switch
		end if

		switch Freddy.State
		case CAM_SHOWSTAGE_0
			if Object.CameraState == 0
				DrawSpriteScreenXY(56, Camera.Scroll, 20)	//stage
			end if
		break
		case CAM_DININGHALL_1
			if Object.CameraState == 1
				DrawSpriteScreenXY(57, Camera.Scroll, 57)	//dining room
			end if
		break		
		case CAM_BATHROOMS_10
			if Object.CameraState == 10
				DrawSpriteScreenXY(58, Camera.Scroll, 52)	//dining room
			end if
		break			
		case CAM_EASTHALL_7
			if Object.CameraState == 7
				DrawSpriteScreenXY(59, Camera.Scroll, 52)	//dining room
			end if
		break		
		case CAM_EHALLCORNER_8
			if Object.CameraState == 8
				DrawSpriteScreenXY(60, Camera.Scroll, 52)	//dining room
			end if
		break				
		end switch


	if Object.CameraState == Bonnie.State
		switch Bonnie.State
		case CAM_SHOWSTAGE_0
			DrawSpriteScreenXY(61, Camera.Scroll, 20)	//stage
		break
		case CAM_DININGHALL_1
			if Bonnie.Pose >= 4
				DrawSpriteScreenXY(64, Camera.Scroll, 52)	//dining room
			else
				DrawSpriteScreenXY(62, Camera.Scroll, 52)	//dining room
			end if
		break		
		case CAM_BACKSTAGE_2
			DrawSpriteScreenXY(63, Camera.Scroll, 52)	//dining room
		break			
		case CAM_WESTHALL_4
			DrawSpriteScreenXY(65, Camera.Scroll, 52)	//dining room
		break			
		case CAM_CLOSET_5
			DrawSpriteScreenXY(66, Camera.Scroll, 52)	//dining room
		break	
		case CAM_WHALLCORNER_6
			DrawSpriteScreenXY(67, Camera.Scroll, 52)	//dining room
		break							
		end switch
	end if

	if Object.CameraState == Foxy.State
		switch Foxy.State
		case CAM_PIRATESCOVE_3
			switch Object.CurtainState
			case 0
				DrawSpriteScreenXY(76, Camera.Scroll, 60)	//stage
			break
			case 1
				DrawSpriteScreenXY(77, Camera.Scroll, 60)	//stage
			break	
			case 2
				//open curtain
				DrawSpriteScreenXY(78, Camera.Scroll, 60)	//stage
				//foxy stare
				DrawSpriteScreenXY(79, Camera.Scroll, 60)	
			break	
			case 3
				//open curtain
				DrawSpriteScreenXY(78, Camera.Scroll, 60)	//stage
				//foxy stare
				DrawSpriteScreenXY(80, Camera.Scroll, 60)	
			break				
			end switch	
			//out order
			if object.camerastate == 3
				DrawSpriteScreenXY(75, Camera.Scroll, 190)	//
			end if		
		break
		case CAM_WESTHALL_4
			
			DrawSpriteScreenFX(81, FX_SCALE, Camera.Scroll, 90)	//


			Object.AnimationTimer += 96
			
			if Object.AnimationTimer > 239
				Object.AnimationTimer -= 240
				
				object.frame++
				if object.frame > 83
					object.frame = 82
				end if
			end if

			DrawSpriteScreenFX(object.frame, FX_SCALE, Camera.Scroll, 90)	//leg
		break
		end switch
	end if



	if object.camerastate == WitheredFreddy.State
		switch WitheredFreddy.State
			case CAM_WESTHALL_4
				DrawSpriteScreenXY(89, Camera.Scroll, 32)	//dining room
			break	
			case CAM_EASTHALL_7
				DrawSpriteScreenXY(90, Camera.Scroll, 52)	//dining room
			break				
		end switch
	end if


		if object.camerastate == Endo.State
			switch Endo.State
				case CAM_BACKSTAGE_2
					if Object.EndoActivate == 0
						DrawSpriteScreenXY(84, Camera.Scroll, 90)	//
					else
						if inputdown.buttonz == 1
							DrawSpriteScreenXY(92, Camera.Scroll, 90)	//
						else
							DrawSpriteScreenXY(85, Camera.Scroll, 90)	//
						end if
					end if
				break
				default
					if inputdown.buttonz == 1
						DrawSpriteScreenXY(92, Camera.Scroll, 90)	//
					else
						DrawSpriteScreenXY(85, Camera.Scroll, 90)	//
					end if
				break
			end switch
		end if



		if object.camerastate == ShadowFreddy.State
			if Object.ShadowFreddyActivate == 1
				DrawSpriteScreenXY(91, 0, 90)	//
			end if
		end if



		if FlashLocked == 0
			if inputdown.buttonz == 1
				temp0=128
				temp0*=512
				temp0>>=9
				

				temp5=256
				temp5*=512
				temp5>>=9

				temp1=screen.xcenter
				temp1-=temp0

				temp2=temp1
				temp2+=temp5

				temp3=120
				temp3-=temp0

				temp4=temp3
				temp4+=temp5

				DrawRect(0, 0, temp1, screen.ysize, 0x00, 0x00, 0x00, 192)
				DrawRect(temp2, 0, screen.xsize, screen.ysize, 0x00, 0x00, 0x00, 192)
				DrawRect(temp1, 0, temp5, temp3, 0x00, 0x00, 0x00, 192)
				DrawRect(temp1, temp4, temp5, screen.ysize, 0x00, 0x00, 0x00, 192)
				
				temp6 = screen.xsize
				temp6 -= screen.xcenter

				object.InkEffect = INK_ALPHA
				object.alpha = 192		
				DrawSpriteScreenFX(74,FX_INK,temp6,screen.ycenter)
				object.alpha = 192

			else
				DrawRect(0, 0, screen.xsize, screen.ysize, 0, 0, 0, 192)// 1
			end if
		else
			DrawRect(0, 0, screen.xsize, screen.ysize, 0, 0, 0, 192)// 1		
		end if	


		if object.camerastate == CAM_KITCHEN_9
			DrawRect(0, 0, screen.xsize, screen.ysize, 0, 0, 0, 255)// 1
		end if	

	end if

	if Object.CameraState == Foxy.State
		if foxy.state == CAM_WESTHALL_4
			object.scale += 12
			else
		end if
	end if	

end event


event ObjectStartup
	
	LoadSpriteSheet("FNAF/CameraScreens.gif")
	
	// Place the HUD object into reserved object slot 4 and initialise its values
	Object[3].Type = TypeName[CamDrawer]
	
	// The object should always be run, regardless if it's within camera bounds or not
	Object[3].Priority = PRIORITY_ACTIVE
	
	// Make the HUD draw ontop of all other sprites, too
	Object[3].DrawOrder = 5
	
	object[3].value9 = screen.xcenter

	// 0-9 - Numbers 0-9
	SpriteFrame(0, 0, 8, 13, 558, 1)
	SpriteFrame(0, 0, 8, 13, 567, 1)
	SpriteFrame(0, 0, 8, 13, 576, 1)
	SpriteFrame(0, 0, 8, 13, 585, 1)
	SpriteFrame(0, 0, 8, 13, 594, 1)
	SpriteFrame(0, 0, 8, 13, 558, 15)
	SpriteFrame(0, 0, 8, 13, 567, 15)
	SpriteFrame(0, 0, 8, 13, 576, 15)
	SpriteFrame(0, 0, 8, 13, 585, 15)
	SpriteFrame(0, 0, 8, 13, 594, 15)

	// 10 - Bar
	SpriteFrame(0, 0, 300, 23, 1, 1)		

	// 11 - camer frames
	SpriteFrame(-220, 15, 459, 36, 1, 25) //11
	SpriteFrame(-240, -25, 487, 76, 1, 62) //12
	SpriteFrame(-270, -90, 540, 166, 1, 139) //13	
	SpriteFrame(-300, -170, 606, 273, 1, 306) //14	
	SpriteFrame(-320, -200, 640, 360, 1, 580) //15
	SpriteFrame(-270, -200, 640, 360, 1, 580) //16	same as 15 but eh

	SpriteFrame(0, 0, 0, 0, 0, 0) //17 BLANK

	//THE SAME ANIMATION BUT BACKWARDS HELP

	SpriteFrame(-320, -200, 640, 360, 1, 580) //18
	SpriteFrame(-300, -170, 606, 273, 1, 306) //19	
	SpriteFrame(-270, -90, 540, 166, 1, 139) //20	
	SpriteFrame(-240, -25, 487, 76, 1, 62) //21
	SpriteFrame(-220, 15, 459, 36, 1, 25) //22
	SpriteFrame(-220, 15, 459, 36, 1, 25) //23 clone

	//old map idk what to do with it	24
	SpriteFrame(0, 0, 200, 172, 823, 851) //24 map big
	//25
	SpriteFrame(0, 0, 24, 24, 889, 1) //25 red baller	
	//26
	SpriteFrame(0, 0, 146, 124, 877, 726) //26 map small

	//27 - 38  Lit cameras

	//27	1A showstage
	//28	1B	dining room
	//29	5	Backstage
	//30	1C	Foxy Land
	//31	2A	West Hall	
	//32	3A	Closet
	//33	2B	W Hall Corner
	//34	4A	East Hall
	//35	4B	E Hall Corner
	//36	6	Kitchen
	//37	7	Bathrooms	
	//38 blank because of codings

	temp1 = 678
	while temp1 < 725
		temp0 = 784
		while temp0 < 876
			SpriteFrame(0, 0, 22, 15, temp0, temp1)
			temp0 += 23
		loop
		temp1 += 16
	loop


	// 39 - Bar
	SpriteFrame(0, 0, 300, 23, 1, 941)	


	SpriteFrame(-260, -260, 512, 384, 1025, 1) //40

	//static
	SpriteFrame(0, 0, 32, 32, 1025, 386)	//41
	SpriteFrame(0, 0, 32, 32, 992, 419)	//42
	SpriteFrame(0, 0, 32, 32, 992, 452)	//43
	SpriteFrame(0, 0, 32, 32, 1025, 386)	//44

	//showstage 1
	SpriteFrame(-220, -200, 480, 270, 806, 1024) //45
	//dinging
	SpriteFrame(-240, -230, 480, 270, 806, 1295) //46
	//couldve been a loop here but idc
	SpriteFrame(-240, -200, 480, 270, 1, 1506) //47
	SpriteFrame(-240, -200, 480, 270, 1, 1767) //48
	//left hall 1
	SpriteFrame(-260, -220, 480, 270, 482, 1566) //49	
	//lcose
	SpriteFrame(-240, -220, 480, 270, 963, 1566) //50	
	SpriteFrame(-240, -200, 480, 270, 1287, 1295) //51		
	
	//right hal
	SpriteFrame(-240, -200, 480, 270, 1, 1225) //52	

	//right hall
	SpriteFrame(-240, -200, 480, 270, 1444, 1566) //53		

	//KITCHEN which is nothign so
	SpriteFrame(-240, -200, 480, 270, 1444, 1566) //55		

	//bath
	SpriteFrame(-260, -200, 480, 263, 1287, 1031) //55		
	
	
	//FREDDY

	//showstage
	SpriteFrame(16, 0, 236, 228, 0, 996)	//56
	SpriteFrame(-19, 0, 24, 55, 238, 996)	//57
	SpriteFrame(-102, 25, 56, 122, 238, 1052)	//58	bath

	SpriteFrame(-22, 15, 29, 60, 263, 991)	//59	hllaway 1
	//hall corner
	SpriteFrame(-116, -12, 184, 202, 295, 1022)	//60	hllaway 1


	//BONNIE

	//showstage
	SpriteFrame(-280, -48, 287, 269, 1287, 761)	//61

	SpriteFrame(35, 0, 50, 100, 1575, 761)	//62

	SpriteFrame(35, 0, 52, 148, 1575, 862)	//63	//backstage

	//dining 2
	SpriteFrame(-128, 32, 147, 166, 1628, 863)	//64

	//left hall 1
	SpriteFrame(-16, 32, 24, 51, 1628, 811)	//65

	//closet
	SpriteFrame(-132, -8, 103, 228, 1653, 634)	//66

	//hall corner
	SpriteFrame(-100, -28, 119, 255, 1346, 386)	//67


	//CHICKEN JOCKEY


	SpriteFrame(-80, -48, 138, 195, 1025, 597)	//68

	SpriteFrame(-82, -40, 46, 84, 1164, 708)	//69

	SpriteFrame(28, -40, 74, 112, 1164, 595)	//70
	SpriteFrame(-150, -40, 256, 128, 564, 1837)	//71
	SpriteFrame(-50, -40, 186, 148, 821, 1837)	//72
	
	//hall corner
	SpriteFrame(-30, -40, 126, 187, 1466, 386)	//73


	//flash ig? lol
	SpriteFrame(-128,-128,256,256,1791,1)	//74

	//FOXY BUT NOT REALLY

	//out of order sign
	SpriteFrame(50, -40, 75, 68, 482, 1930)	//75

	//curtain one
	SpriteFrame(-85, -30, 180, 158, 1305, 1837)	//76	

	SpriteFrame(-85, -30, 180, 158, 1486, 1837)	//77

	SpriteFrame(-85, -30, 179, 158, 1668, 1837)	//78	

	SpriteFrame(-80, 20, 95, 168, 1925, 1668)	//79		

	SpriteFrame(-160, 20, 185, 158, 1848, 1837)	//80		

	//runing
	SpriteFrame(-120, 40, 172, 166, 1538, 1)	//81

	//leg frames
	SpriteFrame(-120, 180, 188, 98, 1538, 168)	//82
	SpriteFrame(-120, 180, 188, 98, 1538, 267)	//83


	//endo who the f

	SpriteFrame(-65, -20, 93, 153, 1776, 928)	//84
	SpriteFrame(-120, -80, 230, 248, 1593, 366)	//85


	//prize corner
	SpriteFrame(-240, -200, 480, 270, 1, 1) //86

	SpriteFrame(-75, 40, 161, 52, 1, 272) //87	

	SpriteFrame(-25, 40, 67, 136, 482, 1) //88


	//withered fredrick
	SpriteFrame(-25, 40, 175, 194, 630, 1371) //89

	SpriteFrame(-120, 40, 138, 154, 667, 1216) //90	


	//shadow fredo
	SpriteFrame(0, -80, 203, 270, 1, 596)	//85

	SpriteFrame(-120, -80, 230, 248, 205, 596)	//92	
end event


// ========================
// Editor events
// ========================

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("3D_Test/Objects.gif")
	SpriteFrame(0, 0, 24, 16, 206, 58)

	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
